//
//  TYHDefineFunction.h
//  OpenPractice
//
//  Created by tanyuehong on 6/7/18.
//  Copyright © 2018年  lijinghua. All rights reserved.
//

#ifndef TYHDefineFunction_h
#define TYHDefineFunction_h



#define kOPNavigationBarHeight        44
#define kOPNaviagtionBarFontSize      19
#define kOPBottomSpace                (DeviceIsIphoneX?34:0)
#define kOPTabBarHeight               (DeviceIsIphoneX?(49+34):49)

#define kAdaptedIpadWidth4(width)     (width * (kScreenWidth / 320))
#define kAdaptedIpadWidth47(width)    (width * (kScreenWidth / 375))
#define kScreenHeight                 [[UIScreen mainScreen] bounds].size.height
#define kScreenWidth                  [[UIScreen mainScreen] bounds].size.width


#define kNavigationBarBottom          (kZDStatusBarHeight + kOPNavigationBarHeight)
#define kContentHeight                kScreenHeight - (kNavigationBarBottom) - 34
#define kOPSafeBlock(block, ...)      (!block ?: block(__VA_ARGS__))

#define DeviceIsPad                   (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define DeviceIsPhone                 (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

// 去除Warc-performSelector-leaks警告
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)

// 去除Wundeclared-selector警告
#define SuppressSelectorDeclaredWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wundeclared-selector\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)

#pragma mark - System Version
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)


#endif /* TYHDefineFunction_h */
